package iteratorExample;
import java.util.Iterator;
import java.util.Vector;

public class IteratorTest {
    public static void main(String[] args) {
        Vector vec = new Vector(3);
        for(int i = 1;i<9;++i)
            vec.addElement(i);
        System.out.println("vector的值为:>"+vec);
        for(Iterator it = vec.iterator();it.hasNext();)
        {
            int x = ((Integer)it.next()).intValue();
            if(x == 2)
                it.remove();
        }
        System.out.println("vector中的组件数为:>"+vec.size());
        if(vec.contains(2))
            System.out.println("找到值等于2的组件");
        else
            System.out.println("找不到值等于2的组件");
        for(var e:vec)
            System.out.println(e);
    }
}
